package com.ruoyi.weixin.controller;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.weixin.domain.KssCourses;
import com.ruoyi.weixin.service.IKssCoursesService;
import com.ruoyi.weixin.service.ITestService;
import com.ruoyi.weixin.vo.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Description: TODO
 * @Author ONESTAR
 * @Date: 2021/9/30 10:23
 * @Version 1.0
 */
@RestController
public class Test1Controller extends BaseController {

    @Autowired
    private IKssCoursesService kssCoursesService;

    @RequestMapping("/loadcourse")
    public R test() {
        KssCourses kssCourses = new KssCourses();
        List<KssCourses> list = kssCoursesService.selectKssCoursesList(kssCourses);
        return R.ok().data("courses", list);
    }

    /**
     * 跳转课程明细
     *
     * @param id
     * @param modelMap
     * @return
     */
    @GetMapping("coursedetail/{id}")
    public String coursedetail(@PathVariable("id") String id, ModelMap modelMap) {
        // 1：根据课程ID查询课程信息
        KssCourses course = kssCoursesService.selectKssCoursesById(id);
        // 2：把课程信息放入到作用域中
        modelMap.put("course", course);
        // 3：返回课程明细的视图
        return "coursedetail";
    }



}
